using System.Reactive.Subjects;
using System.Reactive.Linq;

namespace ReactiveChannelMessaging.Core;

/// <summary>
/// 消息基类
/// </summary>
public abstract record Message(Guid Id, DateTime Timestamp, string Source);

/// <summary>
/// 数据消息
/// </summary>
public record DataMessage(
    Guid Id, 
    DateTime Timestamp, 
    string Source, 
    string Content,
    int Priority = 0
) : Message(Id, Timestamp, Source);

/// <summary>
/// 事件消息
/// </summary>
public record EventMessage(
    Guid Id, 
    DateTime Timestamp, 
    string Source, 
    string EventType,
    object? EventData = null
) : Message(Id, Timestamp, Source);

/// <summary>
/// 命令消息
/// </summary>
public record CommandMessage(
    Guid Id, 
    DateTime Timestamp, 
    string Source, 
    string Command,
    Dictionary<string, object>? Parameters = null
) : Message(Id, Timestamp, Source);

/// <summary>
/// 响应消息
/// </summary>
public record ResponseMessage(
    Guid Id, 
    DateTime Timestamp, 
    string Source, 
    Guid CorrelationId,
    bool Success,
    object? Result = null,
    string? Error = null
) : Message(Id, Timestamp, Source);